import pymysql

#创建数据库连接
conn = pymysql.connect(host="192.168.40.143", user="root", password="123456", database="litemall", port=3306)

#创建游标cursor
cursor = conn.cursor()

try:
    #执行SQL
    cursor.execute("update litemall_goods set name='母亲节礼物-舒适安睡组合new' where id=1181000 ")
    conn.commit() #提交事务
except Exception as e:
    conn.rollback() #回滚事务， 把数据库的状态恢复到运行错误SQL之前的状态

#关闭游标
cursor.close()

#关闭连接
conn.close()
